package com.sc.VenusQueryBeta.model.login;

import com.hengjun.kingstar.sdk.base.BaseModel;
import com.hengjun.kingstar.sdk.helper.RetrofitCreateHelper;
import com.hengjun.kingstar.sdk.helper.RxHelper;
import com.sc.VenusQueryBeta.api.Host;
import com.sc.VenusQueryBeta.api.login.LoginApi;
import com.sc.VenusQueryBeta.contract.login.LoginContract;
import com.sc.VenusQueryBeta.model.bean.login.EquipmentLoginBean;
import com.sc.VenusQueryBeta.model.bean.login.FirstLoginSubmintBean;
import com.sc.VenusQueryBeta.model.bean.login.UsersLoginBean;

import io.reactivex.Observable;

/**
 * Created by SC-02 on 2018/9/19.
 * 登錄model 继承Basemodel 并且实现契约累的model方法
 */


public class LoginModel extends BaseModel implements LoginContract.ILoginModel {
   public  static LoginModel newInstance(){
       return new LoginModel();
   }


    @Override
    public Observable<UsersLoginBean> login(String id, String password, String smsCode, String deviceUID, String token) {
        //用户登录
        return RetrofitCreateHelper.createApi(LoginApi.class, Host.HostVGSestMessageserver).getUsersLogin(id,password,smsCode,deviceUID,token).compose(RxHelper.<UsersLoginBean>rxSchedulerHelper());
    }

    @Override
    public Observable<EquipmentLoginBean> getFirstBUserLoginCode(String clientUID, String deviceUID, String deviceType, String registerSmsnum) {
        //第一次登陆设备，获取验证码
        return RetrofitCreateHelper.createApi(LoginApi.class, Host.HostVGSestMessageserver).EpLogin( clientUID,  deviceUID,  deviceType, registerSmsnum).compose(RxHelper.<EquipmentLoginBean>rxSchedulerHelper());
    }

    @Override
    public Observable<FirstLoginSubmintBean> firstSumbit(String id, String smsCode, String password, String clientUID, String deviceUID, String deviceType) {
        //第一次登录的页面确定后继续掉通过伺服器确认注册
        return RetrofitCreateHelper.createApi(LoginApi.class, Host.HostVGSestMessageserver).firstsubmint(id,smsCode,password,clientUID,deviceUID,deviceType).compose(RxHelper.<FirstLoginSubmintBean>rxSchedulerHelper());
    }
}
